package org.freedoit.server.service.task;

import org.freedoit.server.om.Task;
import org.freedoit.server.service.ServiceManager;
import org.freedoit.server.service.data.TaskReturnResult;
import org.freedoit.server.util.Utils;
import org.freedoit.shared.data.SharedTask;

public class UpdateTaskServlet extends TaskServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 102304901720346460L;

	/**
	 * 
	 */
	protected void workOnTask(SharedTask sharedTask, Long currentUserId,
			TaskReturnResult result, Long timestamp) {
		// TODO Auto-generated method stub
		Task task = Utils.fromSharedData(sharedTask);
		if (ServiceManager.updateTask(task, timestamp)) {
			result.setCode(TaskReturnResult.CODE_OK);
			result.setTimestamp(timestamp.longValue());
		} else {
			result.setCode(TaskReturnResult.CODE_INVALID_DATA);
		}
	}

}
